import json

from django.shortcuts import render
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView


# Create your views here.
class TestView(APIView):
    """
    测试jwt用户id的获取
    """
    permission_classes = [IsAuthenticated]

    def post(self, request):
        print(request.user)  # 能获取到用户信息
        data = {
            "username": str(request.user)
        }
        return Response({'message': "已经登录认证了", 'data_token': json.dumps(data)})
